
	//物联监控系统
	function Material() {}
	//Material.prototype.remoteUrl = "http://183.230.183.18:8088/SPPMMaterial/services/MaterialQuery/";
	Material.prototype.remoteUrl = "http://127.0.0.1:8080/SPPMMaterial/services/MaterialQuery/";
	
	//获取区域
	Material.prototype.getZones = function(callback){
		$('#dg_zones').datagrid({     
		    url:this.remoteUrl+"getZones", 
		    columns:[[
		        {field:'id',title:'ID',width:300},     
		        {field:'parent',title:'上级区域',width:100},
		        {field:'name',title:'名称',width:100},
		        {field:'remark',title:'备注',width:250},
		        {field:'created',title:'创建时间',width:180},
		        {field:'updated',title:'修订时间',width:180}
		    ]]
		});
	}
	
	Material.prototype.getDevices = function(callback){
	
		$('#dg_devices').datagrid({ 
			loadMsg : "正在加载数据",
		    url:this.remoteUrl+"getDevices", 
		    columns:[[
		        {field:'id',title:'ID',width:300},     
		        {field:'zone_name',title:'区域',width:100},     
		        {field:'vendor',title:'供应商',width:100},
		        {field:'kind',title:'设备类型',width:100},
		        {field:'link',title:'设备接入方式',width:100},
		        {field:'name',title:'名称',width:100},
		        {field:'number',title:'序列号',width:100},
		        {field:'degree',title:'最近观测值',width:100},
		        {field:'feed',title:'状态',width:100},
		        {field:'alarm',title:'告警状态',width:100},
		        {field:'remark',title:'备注',width:100},
		    ]],
		    
		    onClickRow:function(rowIndex,rowData){
			   onDeviceRowSeleted(rowData);
			 },
		});   
	}
	
	function onDeviceRowSeleted(data){
		
		window.location.href = "record.html?id="+data.id;
	}
	
	Material.prototype.getDeviceStatus = function(callback){
		$.post(this.remoteUrl+"getDeviceStatus",{},function(data){
			var x = data;
		});
		var xmlStr = "";
	}
	
	Material.prototype.getDeviceRecords = function(deviceid,callback){
		
		$.post(this.remoteUrl+"getDeviceRecordsOneDay",{para:deviceid},function(data){
			if(callback) callback.call(window,data);
		});
		/*$('#dg_records').datagrid({     
		    url:this.remoteUrl+"getDeviceRecords", 
		    queryParams:{'deviceid':deviceid},
		    columns:[[
		        {field:'id',title:'ID',width:300},     
		        {field:'device_name',title:'关联设备',width:300},     
		        {field:'origin',title:'请求源',width:100},
		        {field:'degree',title:'读数',width:150},
		        {field:'degree',title:'读数',width:150},
		        {field:'feed',title:'工作状态',width:180},
		        {field:'alarm',title:'警告',width:180},
		         {field:'created',title:'产生时间',width:180}
		    ]]
		});   */
	}
	
	
	
	Material.prototype.saveDeviceRecords = function(callback){
		
		$.post(this.remoteUrl+"saveDeviceRecords",{},function(data){
			
		});
		
	}
	
	
	Material.prototype.onerror = function(errStr,callback){
		var xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><data><error>错误信息</error><zone><id></id><name></name><remark></remark><created></created><updated></updated></zone></data>";
	}
	
	
